# Database Modelling
Take your time to think about the tables that you will create. Pay close attention to the relationships between your tables.
Use pen and paper or a whiteboard and draw some sketches first.
Learn about Entity Relationship Diagrams (ERD) (opens new window)
# ERD
Entity Relationship Diagrams
- Lucidchard
# Entities
- Entities - rows
- Attributes -columns
# Relationships
Describe, how the elements interact with each other
# Cardinality
Think: what is the minimum and maximum:
Zero or many:
# Primary Key
Rules
- unique
- never changing
- never null
- one PK per table
# Foreign Key
- Foreign Key dont have to be uniqe, they can be repeated
- There can be multiple Foreign Keys in one entity
# Composite Primary Key
when 2 or more attributes are nescessary to uniquly idetify a record
# Rules:
- Use the fewest amout of attributes possible
- Don't use attributes that are apt to change
# Bridge Table
Breaks up the many-to-many relationship